package com.wangy.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter {

	private final static String DATE_PATTERN = "yyyy-MM-dd";
	private final static String TIME_PATTERN = "HH:mm:ss";
	private final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

	public static String convert(Date date, String pattern) {
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		return format.format(date);
	}

	public static String convertDate(Date date) {
		return convert(date,DATE_PATTERN);
	}

	public static String convertTime(Date date) {
		return convert(date,TIME_PATTERN);
	}

	public static String convertDateTime(Date date) {
		return convert(date,DATE_TIME_PATTERN);
	}
	
	public static void main(String[] args) {
		System.out.println(convertTime(new Date()));
	}
}
